package desktop.lan.cooperate;

import java.rmi.RemoteException;

import desktop.conf.key.KeyConfDefault;
import desktop.core.playfield.PlayFieldModel;
import desktop.lan.remote.key.KeyRemoteImpl;
import desktop.lan.remote.key.KeyRemoteServer;
import desktop.lan.remote.playfieldmodel.PlayFieldModelRemoteImpl;
import desktop.lan.remote.playfieldmodel.PlayFieldModelRemoteServer;

public class LanCooperateServer implements Runnable {

	private PlayFieldModelRemoteImpl playFieldModelRemoteImpl;
	private KeyRemoteImpl keyRemoteImpl;

	public LanCooperateServer(PlayFieldModel playFieldModel) {
		try {
			playFieldModelRemoteImpl = new PlayFieldModelRemoteImpl(
					playFieldModel);
			keyRemoteImpl = new KeyRemoteImpl(new KeyConfDefault());
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}

	public PlayFieldModelRemoteImpl getPlayFieldModelRemoteImpl() {
		return playFieldModelRemoteImpl;
	}

	public KeyRemoteImpl getKeyRemoteImpl() {
		return keyRemoteImpl;
	}

	@Override
	public void run() {
		new PlayFieldModelRemoteServer(playFieldModelRemoteImpl,
				"PlayFieldModelRemote");
		new KeyRemoteServer(keyRemoteImpl, "KeyRemoteLeft");
	}
}